import { createRouter, createWebHistory } from 'vue-router'
import index from '@/views/index.vue'
import login from '@/views/login.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: index,
      redirect: '/login',
      children: [
        {
          path: '/home',
          name: 'home',
          meta: {
            title: '首页',
            icon: 'icon-home'
          },
          component: () => import('@/views/index_pages/home.vue')
        },
        {
          path: '/video',
          name: 'video',
          meta: {
            title: '视频管理',
            icon: 'icon-video'
          },
          component: () => import('@/views/index_pages/video.vue')
        },
        {
          path: '/mall',
          name: 'mall',
          meta: {
            title: '商城管理',
            icon: 'icon-mall'
          },
          children: [
            {
              path: '/mall/store',
              name: 'store',
              meta: {
                title: '店铺管理',
                icon: 'icon-mall',
                hidden: true
              },
              component: () => import('@/views/index_pages/store.vue')
            },
            {
              path: '/mall/goods/:id',
              name: 'goods',
              meta: {
                title: '商品管理',
                icon: 'icon-mall',
                hidden: true
              },
              component: () => import('@/views/index_pages/goods.vue')
            },
          ]
        },
        {
          path: '/member',
          name: 'member',
          meta: {
            title: '会员管理',
            icon: 'icon-member'
          },
          component: () => import('@/views/index_pages/member.vue')
        },
        {
          path: '/order',
          name: 'order',
          meta: {
            title: '订单管理',
            icon: 'icon-order'
          },
          component: () => import('@/views/index_pages/order.vue')
        },
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: login
    }
  ]
})

export default router
